// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.chips;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class ByteTripod implements Chip {
  public byte D1 = 0;
  public boolean D1_ACTIVE = false;
  
  public byte D2 = 0;
  public boolean D2_ACTIVE = false;
  
  public byte D3 = 0;
  public boolean D3_ACTIVE = false;
  
  public void update() {
    boolean active = D1_ACTIVE && D2_ACTIVE && D3_ACTIVE;
    
    if (active) {
      byte data = D1;
      if (D2_ACTIVE) data |= D2;
      if (D3_ACTIVE) data |= D3;
      
      if (!D1_ACTIVE) D1 = data;
      if (!D2_ACTIVE) D2 = data;
      if (!D3_ACTIVE) D3 = data;
    }
  }
}
